const app = getApp();
Page({
  data: {
    focus: false,
    inputValue: '',
    respData: {}
  },
  bindDateChange: function (e) {
    this.setData({
      date: e.detail.value
    })
  },
  bindTimeChange: function (e) {
    this.setData({
      time: e.detail.value
    })
  },
  onLoad: function (options) {
    // wx.hideKeyboard();
    var that = this;
    var openId = wx.getStorageSync('openId');
    this.setData({
      openId: openId,
    });
    wx.showLoading({
      title: '数据加载中'
    });
    this.requestData(openId,function(){
      that.setData({
        introduce: that.data.respData.introduce,
        address: that.data.respData.site
      })
    })

    //请求后台数据
  },
  bindTextAreaBlur: function (e) {
    console.log(e.detail.value)
  },
  onReady: function () {
   
  },
  //请求后台数据
  requestData: function (openId,callback) {
    var that = this;
    console.log('requestData');
    wx.request({
      url: app.globalData.mpurl + 'user/getInfo',
      method: "GET",
      data: {
        openId: openId,
      },
      success: function (res) {
        res = res.data;
        console.log(res);
        if (res.code == '00' || res.code == '05') {
          that.setData({ respData: res.data });
          if (res.code == '05') {
            wx.showModal({
              title: '提示',
              content: '信息不全或未确认信息,请关注公众号后修改',
              showCancel: false,
            })
          }

        } else {
          wx.showModal({
            title: '提示',
            content: '获取信息失败',
            showCancel: false,
          })
        }
      },
      fail: function (res) {
        wx.showModal({
          title: '提示',
          content: "系统异常，请稍候再试",
          showCancel: false
        })
      },
      complete: function () {
        wx.hideLoading();
        callback();
      }
    });

  },
  updateInfo: function () {
    wx.showModal({
      title: '提示',
      content: "小程序暂不支持修改，请关注公众号并修改",
      showCancel: false
    })
  },
  onPullDownRefresh: function () {
    console.log("onPullDownRefresh");
    wx.showNavigationBarLoading();
    this.onLoad();
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新
  },

})
